package com.hemi.rhet.util;

import android.annotation.SuppressLint;
import android.os.Environment;
import android.os.StrictMode;

import com.hemi.rhet.Constants;

@SuppressLint("NewApi")
public class OSInfoUtil {

	public static String getOsInfo() {

		String phoneInfo = "Product: " + android.os.Build.PRODUCT;
		phoneInfo += ", CPU_ABI: " + android.os.Build.CPU_ABI;
		phoneInfo += ", TAGS: " + android.os.Build.TAGS;
		phoneInfo += ", VERSION_CODES.BASE: "
				+ android.os.Build.VERSION_CODES.BASE;
		phoneInfo += ", MODEL: " + android.os.Build.MODEL;
		phoneInfo += ", SDK: " + android.os.Build.VERSION.SDK;
		phoneInfo += ", VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE;
		phoneInfo += ", DEVICE: " + android.os.Build.DEVICE;
		phoneInfo += ", DISPLAY: " + android.os.Build.DISPLAY;
		phoneInfo += ", BRAND: " + android.os.Build.BRAND;
		phoneInfo += ", BOARD: " + android.os.Build.BOARD;
		phoneInfo += ", FINGERPRINT: " + android.os.Build.FINGERPRINT;
		phoneInfo += ", ID: " + android.os.Build.ID;
		phoneInfo += ", MANUFACTURER: " + android.os.Build.MANUFACTURER;
		phoneInfo += ", USER: " + android.os.Build.USER;
		return phoneInfo;
	}

	public static void version4Adapter() {
		String strVer = android.os.Build.VERSION.RELEASE;
		strVer = strVer.substring(0, 3).trim();
		float fv = Float.valueOf(strVer);
		if (fv > 2.3) {
			StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
					.detectDiskReads().detectDiskWrites().detectNetwork()
					.penaltyLog().build());
			StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()
					.detectLeakedSqlLiteObjects().detectLeakedSqlLiteObjects()
					.penaltyLog().penaltyDeath().build());

		}

	}
	
	/**
	 * 判读是否有SD卡
	 * @return
	 */
	public static boolean hasSDC(){
		return Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED);
	}
	public static String trAppNameUrl(String url ){
		String appPath = "/"+Constants.app_name;
		String res= url;
		if(url.indexOf(appPath)!=-1)
		{
			res = url.substring(url.indexOf(appPath)+appPath.length(), url.length());
		} 
		return res;
	}
	

}
